home *** CD-ROM | disk | FTP | other *** search
/ Especial Multimedia / Especial Multimedia.iso / Multimed / Visuali / RESUME.ZIP / RESUME.CPP < prev    next >
C/C++ Source or Header  |  1997-02-10  |  39KB  |  1,237 lines

  1. // RESUME.CPP    Cyber-Resume
  2. //               Version 1.0, July, 1996
  3.  
  4. #include <windows.h>
  5. #include <bwcc.h>
  6. #include <commdlg.h>
  7. #include <mmsystem.h>
  8. #include <memory.h>
  9. #include <string.h>
  10. #include <dir.h>
  11. #include <fstream.h>
  12. #include <iostream.h>
  13. #include <io.h>
  14. #include <dos.h>
  15. #include <mem.h>
  16. #include <stdio.h>
  17. #include <conio.h>
  18. #include <stdlib.h>
  19. #include <alloc.h>
  20. #include "pcxhead.i"
  21. #include "resume.h"
  22.  
  23. long FAR PASCAL _export WndProc(HWND,UINT,UINT,LONG);
  24. long FAR PASCAL ChildProc(HWND,UINT,UINT,LONG);
  25. void MoveCaret(HWND,int,int,int);
  26.  
  27. #define BUFFSIZE 128
  28. #define WIDTH(x)  (x.right-x.left)
  29. #define HEIGHT(x) (x.bottom-x.top)
  30. // This for printer
  31. #define HORZMARGIN 0.25
  32. #define VERTMARGIN 0.25
  33. // This for editor
  34. #define XSTART 10
  35. #define YSTART 60
  36. #define XCARETWIDTH 2
  37. #define YCARETHEIGHT 35
  38. #define BORDER 10
  39. #define BORDER2 20
  40. #define TOPBORDER 60
  41. // WM_COMMAND values
  42. #define MY_EDIT_RETURN    0x0401
  43. #define MY_TEXT_BUTTON_0  0x0500
  44. #define MY_TEXT_BUTTON_1  0x0501
  45. #define MY_TEXT_BUTTON_2  0x0502
  46. #define MY_TEXT_BUTTON_3  0x0503
  47. #define MY_TEXT_BUTTON_4  0x0504
  48. #define MY_TEXT_BUTTON_5  0x0505
  49. #define MY_TEXT_BUTTON_6  0x0506
  50. #define MY_TEXT_BUTTON_7  0x0507
  51. #define MY_TEXT_BUTTON_8  0x0508
  52. #define MY_IMAGES_BUTTON  0x0509
  53. #define MY_IMAGE_NEXT     0x0510
  54. #define MY_IMAGE_BACK     0x0511
  55. #define MY_VIDEO_BUTTON   0x0512
  56. #define MY_VIDEO_PLAY     0x0513
  57. #define MY_VIDEO_PAUSE    0x0514
  58. #define MY_VIDEO_REWIND   0x0515
  59. #define MY_VOICE_BUTTON   0x0516
  60. #define MY_EXIT           0x0517
  61.  
  62. PSTR szProgName = "Cyber-Resume for Windows";
  63. char szAppName[32];
  64. char szPath[BUFFSIZE] = "resume.txt";
  65. char szTitle[BUFFSIZE];
  66. char szString[BUFFSIZE];
  67. char achString[BUFFSIZE];
  68. char TextButton[9][20],ButtonTitle[20];
  69. char images[24][16];
  70. char captions[24][80];
  71. RECT     cRect;
  72. HBITMAP  hmemBitmap,hundomemBitmap;
  73. HFONT    hFontText;
  74. HDC      hmemDC,hundomemDC;
  75. BOOL     Shareware = FALSE;
  76. char     Text[80][80];
  77. int      nLineSpacing,nNumLines;
  78. int      VertOldPos,VertScrollPos,VertMaxScroll;
  79. int      nImageNum,nNumImages;
  80.  
  81. int ErrorMsg( HWND hwnd, char *Message )
  82. {
  83.     MessageBox( hwnd, Message, "Error!",MB_ICONEXCLAMATION | MB_OK );
  84.     return(0);
  85. }
  86.  
  87. BOOL GetaLine(HFILE hFile,LPSTR lineBuf,UINT *linelength)
  88. {
  89.  int flag,count = 0;
  90.  char temp[2];
  91.  
  92.  lineBuf[0] = 0x00; *linelength = 0;
  93.  do{flag = _lread(hFile,temp,1);
  94.      if (flag == HFILE_ERROR) return FALSE;
  95.  
  96.      // check for CR
  97.  
  98.      if (temp[0]==0x0D)
  99.       {_lread(hFile,temp,1); // skip over LF
  100.         *linelength = count;
  101.         lineBuf[count] = NULL;
  102.         break;
  103.       }
  104.      lineBuf[count++] = temp[0];
  105.     } while (flag==1);
  106.  if (flag==1)  return TRUE; else return FALSE;
  107. }
  108.  
  109. void PrintTextFile(HWND hWnd,PSTR szDocName,LPSTR szFileName)
  110. {
  111.  HFILE hFile;
  112.  PRINTDLG pd;
  113.  DOCINFO di;
  114.  TEXTMETRIC tm;
  115.  HCURSOR hCursor,holdCursor;
  116.  char lineBuf[128],temp[128];
  117.  int yChar,yPage,yPos,xPixels,yPixels,xMargin,yMargin;
  118.  UINT linelength;
  119.  
  120.  // open file
  121.  hFile = _lopen(szFileName,READ);
  122.  if (hFile == HFILE_ERROR)
  123.     {
  124.      wsprintf(temp,"\n %s file not found",szFileName);
  125.      BWCCMessageBox(hWnd,temp,"Error",MB_OK | MB_ICONINFORMATION);
  126.      return;
  127.     }
  128.  // set up PRINTDLG structure
  129.  memset(&pd,0,sizeof(PRINTDLG));
  130.  pd.lStructSize = sizeof(PRINTDLG);
  131.  pd.hwndOwner = hWnd;
  132.  pd.Flags = PD_RETURNDC | PD_NOPAGENUMS |
  133.                 PD_NOSELECTION | PD_HIDEPRINTTOFILE;
  134.  // call Print common dialog
  135.  if (!PrintDlg(&pd)) return; // if NULL return foget it
  136.  // change cursor to hourglass
  137.  hCursor = LoadCursor(NULL,IDC_WAIT);
  138.  holdCursor = SetCursor(hCursor);
  139.  // print the text
  140.  di.cbSize = sizeof(DOCINFO);
  141.  di.lpszDocName = szDocName;
  142.  di.lpszOutput = NULL;
  143.  // get text and page dimensions
  144.  GetTextMetrics(pd.hDC,&tm);
  145.  // line height in pixels
  146.  yChar = tm.tmHeight + tm.tmExternalLeading;
  147.  // page height in pixels
  148.  yPage = GetDeviceCaps(pd.hDC,VERTRES);
  149.  // pixels/in. horizontal
  150.  xPixels = GetDeviceCaps(pd.hDC,LOGPIXELSX);
  151.  // pixels/in. vertical
  152.  yPixels = GetDeviceCaps(pd.hDC,LOGPIXELSY);
  153.  // margin at left of page
  154.  xMargin = xPixels * HORZMARGIN;
  155.  // margin at top and bottom of page
  156.  yMargin = yPixels * VERTMARGIN;
  157. /*
  158.   wsprintf(temp,"yChar=%d yPage=%d xPix=%d yPix=%d xMar=%d yMar=%d",yChar,yPage,xPixels,yPixels,xMargin,yMargin);
  159.   BWCCMessageBox(hWnd,temp,"Page Info",MB_OK | MB_ICONINFORMATION);
  160. */
  161.  StartDoc(pd.hDC,&di);
  162.  StartPage(pd.hDC);
  163.  yPos = yMargin;
  164.  while (GetaLine(hFile,lineBuf,&linelength))
  165.   {if (lineBuf[0]==0x0C)
  166.      {
  167.       EndPage(pd.hDC);
  168.       StartPage(pd.hDC);
  169.       yPos = yMargin;
  170.       continue;
  171.      }
  172.     TextOut(pd.hDC,xMargin,yPos,lineBuf,linelength);
  173.     yPos += yChar; // move down a line
  174.     if (yPos > yPage - yMargin - yChar)
  175.      {
  176.       EndPage(pd.hDC);
  177.       StartPage(pd.hDC);
  178.       yPos = yMargin;
  179.      }
  180.   }
  181.  _lclose(hFile);
  182.  EndPage(pd.hDC);
  183.  EndDoc(pd.hDC);
  184.  // clean up
  185.  DeleteDC(pd.hDC);
  186.  if (pd.hDevMode != NULL) GlobalFree(pd.hDevMode);
  187.  if (pd.hDevNames != NULL) GlobalFree(pd.hDevNames);
  188.  SetCursor(holdCursor); // restore cursor
  189. }
  190.  
  191. void PrintGraphicsFile(HWND hWnd,PSTR szDocName)
  192. {
  193.  PRINTDLG pd;
  194.  DOCINFO di;
  195.  TEXTMETRIC tm;
  196.  HCURSOR hCursor,holdCursor;
  197.  RECT cRect;
  198.  int yChar,xPage,yPage,yPos,xPixels,yPixels,xMargin,yMargin;
  199. // char temp[80];
  200.  
  201.   // set up PRINTDLG structure
  202.  memset(&pd,0,sizeof(PRINTDLG));
  203.  pd.lStructSize = sizeof(PRINTDLG);
  204.  pd.hwndOwner = hWnd;
  205.  pd.Flags = PD_RETURNDC | PD_NOPAGENUMS |
  206.                 PD_NOSELECTION | PD_HIDEPRINTTOFILE;
  207.  // call Print common dialog
  208.  if (!PrintDlg(&pd)) return; // if NULL return forget it
  209.  // change cursor to hourglass
  210.  hCursor = LoadCursor(NULL,IDC_WAIT);
  211.  holdCursor = SetCursor(hCursor);
  212.  // print the screen
  213.  di.cbSize = sizeof(DOCINFO);
  214.  di.lpszDocName = szDocName;
  215.  di.lpszOutput = NULL;
  216.  // get text and page dimensions
  217.  GetTextMetrics(pd.hDC,&tm);
  218.  // line height in pixels
  219.  yChar = tm.tmHeight + tm.tmExternalLeading;
  220.  // page width in pixels
  221.  xPage = GetDeviceCaps(pd.hDC,HORZRES);
  222.  // page height in pixels
  223.  yPage = GetDeviceCaps(pd.hDC,VERTRES);
  224.  // pixels/in. horizontal
  225.  xPixels = GetDeviceCaps(pd.hDC,LOGPIXELSX);
  226.  // pixels/in. vertical
  227.  yPixels = GetDeviceCaps(pd.hDC,LOGPIXELSY);
  228.  // margin at left of page
  229.  xMargin = xPixels * HORZMARGIN;
  230.  // margin at top and bottom of page
  231.  yMargin = yPixels * VERTMARGIN;
  232. /*
  233.   wsprintf(temp,"yChar=%d yPage=%d xPix=%d yPix=%d xMar=%d yMar=%d",yChar,yPage,xPixels,yPixels,xMargin,yMargin);
  234.   BWCCMessageBox(hWnd,temp,"Page Info",MB_OK | MB_ICONINFORMATION);
  235. */
  236.  // get screen here
  237.  GetClientRect(hWnd,&cRect);
  238. /*
  239.  wsprintf(temp,"width = %d height = %d",WIDTH(cRect),HEIGHT(cRect));
  240.  BWCCMessageBox(hWnd,temp,"Screen Info",MB_OK);
  241. */
  242.  SetMapMode(pd.hDC,MM_ISOTROPIC);
  243.  SetWindowExt(pd.hDC,WIDTH(cRect),WIDTH(cRect));
  244.  SetViewportExt(pd.hDC,xPage,xPage);
  245.  
  246.  StartDoc(pd.hDC,&di);
  247.  StartPage(pd.hDC);
  248.  
  249.  BitBlt(pd.hDC,0,0,WIDTH(cRect),HEIGHT(cRect),hmemDC,0,0,SRCCOPY);
  250.  
  251.  EndPage(pd.hDC);
  252.  EndDoc(pd.hDC);
  253.  // clean up
  254.  DeleteDC(pd.hDC);
  255.  if (pd.hDevMode != NULL) GlobalFree(pd.hDevMode);
  256.  if (pd.hDevNames != NULL) GlobalFree(pd.hDevNames);
  257.  SetCursor(holdCursor); // restore cursor
  258. }
  259.  
  260. BOOL FAR PASCAL CreateBitmapFromFile(HWND hwnd,LPSTR lpstrFile,
  261.                                                  HBITMAP *hBitmap,HPALETTE *hPal)
  262. // lpstrFile = pointer to name of bitmap file
  263. // hBitmap   = bitmap handle to return new bitmap in
  264. // hPal      = palette handle for new palette
  265. //             only needed for 256 color images
  266. {
  267.   int i,fp;                // loop counter and file handle
  268.   int numEntries;                // number of palette entries in bitmap
  269.   HGLOBAL hGlb;                // global handle used to read in bitmap data
  270.   LPBYTE bmpData;          // pointer to global memory for bitmap data
  271.   LPBYTE dataBits;         // pointer to actual bitmap picture data
  272.   BITMAPFILEHEADER bmfh;   // bitmap file header
  273.   LPBITMAPINFOHEADER bmih; // pointer to bitmap info header
  274.   HDC hDC;                 // device context used to create hBitmap
  275.   LOGPALETTE *LogPal=NULL; // memory pointer to store logical palette in
  276.   LPRGBQUAD lpRGB;         // pointer to RGB quad structures of bitmap
  277.   OFSTRUCT datafile;
  278.  
  279.   if (!hBitmap)
  280.     {ErrorMsg(hwnd,"Invalid parameter");
  281.      return FALSE;
  282.     }
  283.  
  284.   // open bitmap file
  285.   fp = OpenFile(lpstrFile,(LPOFSTRUCT)&datafile,OF_READ);
  286.   if (fp==-1)
  287.     {// ErrorMsg(hwnd,lpstrFile);
  288.      ErrorMsg(hwnd,"Unable to open .BMP file");
  289.      return FALSE;
  290.     }
  291.  
  292.   // read in bitmap file header
  293.   _lread(fp,(LPSTR)&bmfh,sizeof(BITMAPFILEHEADER));
  294.  
  295.   // verify file is type BM (bitmap file)
  296.   if (bmfh.bfType!=0x4D42)
  297.     {_lclose(fp);
  298.      ErrorMsg(hwnd,"Invalid file");
  299.      return FALSE;
  300.     }
  301.  
  302.   // allocate global memory to store bitmap data in
  303.   hGlb = GlobalAlloc(GHND,filelength(fp));
  304.   bmpData = (LPBYTE)GlobalLock(hGlb);
  305.  
  306.   // verify memory properly allocated
  307.   if (!bmpData)
  308.     {if (hGlb) GlobalFree(hGlb);
  309.      _lclose(fp);
  310.      ErrorMsg(hwnd,"Memory allocation failed");
  311.      return FALSE;
  312.     }
  313.  
  314.   // read in bitmap
  315.   _hread(fp,(LPSTR)bmpData,bmfh.bfSize-sizeof(BITMAPFILEHEADER));
  316.   _lclose(fp); // no longer need file handle
  317.  
  318.   // get pointer to bitmap info header
  319.   bmih = (LPBITMAPINFOHEADER)bmpData;
  320.  
  321.   // get pointer to actual bitmap data
  322.   dataBits =
  323.      (LPBYTE)((LONG)bmpData+(LONG)bmfh.bfOffBits-sizeof(BITMAPFILEHEADER));
  324.  
  325.   // get pointer to RGB quad structures
  326.   lpRGB = (LPRGBQUAD)((LONG)bmih+sizeof(BITMAPINFOHEADER));
  327.  
  328.   // determine the number of palette entries based on number of colors
  329.   if (bmih->biBitCount==1) numEntries = 2;
  330.   else if (bmih->biBitCount==4) numEntries = 16;
  331.   else if (bmih->biBitCount==8) numEntries = 256;
  332.   else if (bmih->biBitCount==24) numEntries = 0; // no palette for 24 bit
  333.  
  334.   // get a screen device context
  335.   hDC = GetDC(NULL);
  336.  
  337.   // read in logical palette
  338.   if (numEntries&&hPal)
  339.     {// get memory to read palette into
  340.      LogPal =
  341.         (LOGPALETTE*)LocalAlloc(LPTR,
  342.          sizeof(LOGPALETTE)+numEntries*sizeof(PALETTEENTRY));
  343.       if (LogPal==NULL)
  344.         {ErrorMsg(hwnd,"Memory allocation failed LogPal");
  345.          return FALSE;
  346.         }
  347.      // setup logpalette structure
  348.      LogPal->palVersion = 0x300;
  349.      LogPal->palNumEntries = numEntries;
  350.      for (i=0;i<numEntries;i++)
  351.       {LogPal->palPalEntry[i].peRed = lpRGB[i].rgbRed;
  352.         LogPal->palPalEntry[i].peGreen = lpRGB[i].rgbGreen;
  353.         LogPal->palPalEntry[i].peBlue = lpRGB[i].rgbBlue;
  354.         LogPal->palPalEntry[i].peFlags = 0;
  355.       }
  356.  
  357.      // create the palette using the bitmap's logical palette
  358.      *hPal = CreatePalette((LPLOGPALETTE)LogPal);
  359.  
  360.      // set palette into the device context
  361.      SelectPalette(hDC,*hPal,TRUE);
  362.      RealizePalette(hDC);
  363.     }
  364.   else if (hPal) *hPal = NULL;
  365.  
  366.   // create the bitmap in the device context
  367.   *hBitmap = CreateDIBitmap(hDC,bmih,CBM_INIT,(LPSTR)dataBits,
  368.                                      (LPBITMAPINFO)bmih,DIB_RGB_COLORS);
  369.  
  370.   // perform cleanup
  371.   ReleaseDC(NULL,hDC);
  372.   if (LogPal) LocalFree((LOCALHANDLE)LogPal); // my LOCALHANDLE addition
  373.   GlobalUnlock(hGlb);
  374.   GlobalFree(hGlb);
  375.  
  376.   // verify bitmap created
  377.   if(!*hBitmap)
  378.     {if (hPal&&*hPal) DeleteObject(*hPal);
  379.      ErrorMsg(hwnd,"Create bitmap failure");
  380.      return FALSE;
  381.     }
  382.  
  383.   return TRUE;
  384. }
  385.  
  386. BOOL FAR PASCAL DrawBitmap(HWND hwnd,HBITMAP hBitmap,
  387.                                     HPALETTE hPal,HDC hDC,int x,int y)
  388. // hBitmap = handle of bitmap to be drawn
  389. // hPal    = palette of bitmap, if necessary (may ne NULL)
  390. // hDC     = device context bitmap to be drawn on
  391. // x,y     = location bitmap to be drawn on device context
  392. {
  393.  BITMAP bitmap;        // structure to hold bitmap statistics
  394.  HDC hDCMem;         // memory DC to place bitmap in
  395.  POINT bSize,origin; //
  396.  RECT cRect;
  397.  
  398.  if (!hBitmap || !hDC)
  399.   {ErrorMsg(hwnd,"Invalid parameter");
  400.     return FALSE;
  401.   }
  402.  GetClientRect(hwnd,&cRect);
  403.  
  404.  // create a compatable memory dc to place bitmap in
  405.  hDCMem = CreateCompatibleDC(hDC);
  406.  
  407.  // selete bitmap into memory DC
  408.  SelectObject(hDCMem,hBitmap);
  409.  
  410.  // set mapping modes to be equivalent
  411.  SetMapMode(hDCMem,GetMapMode(hDC));
  412.  
  413.  // get statistics of bitmap
  414.  GetObject(hBitmap,sizeof(BITMAP),(LPSTR)&bitmap);
  415.  
  416.  // convert size and origin of bitmap to logical coordinates
  417.  bSize.x = bitmap.bmWidth;
  418.  bSize.y = bitmap.bmHeight;
  419.  DPtoLP(hDC,&bSize,1);
  420.  origin.x = origin.y = 0;
  421.  DPtoLP(hDCMem,&origin,1);
  422.  
  423.  // if palette is provided, set dc to use it
  424.  if (hPal)
  425.   {SelectPalette(hDC,hPal,FALSE);
  426.     RealizePalette(hDC);
  427.   }
  428.  
  429.  // draw bitmap onto passed in device context
  430.  if (x<0&&y<0)
  431.    BitBlt(hDC,(WIDTH(cRect)-bSize.x)/2,(HEIGHT(cRect)-40-bSize.y)/2,bSize.x,bSize.y,hDCMem,origin.x,origin.y,SRCCOPY);
  432.  else
  433.     BitBlt(hDC,x,y,bSize.x,bSize.y,hDCMem,origin.x,origin.y,SRCCOPY);
  434.  
  435.  // cleanup
  436.  DeleteDC(hDCMem);
  437.  
  438.  return TRUE;
  439. }
  440.  
  441. void parser(char *line,char *temp,UINT linelength)
  442. {
  443.  int i=0;
  444.  
  445.  for (i=0;i<=linelength;i++)
  446.   {
  447.     *(temp+i) = *(line+i);
  448.     if (*(temp+i)==' '||*(temp+i)==NULL)
  449.      {
  450.       *(temp+i) = NULL;
  451.       break;
  452.      }
  453.   }
  454. }
  455.  
  456. int Read_Title(HWND hWnd,HFILE hFile)
  457. {
  458.  char lineBuf[128],temp[128],original[128];
  459.  char *token[6],fontname[32],fontsize[4];
  460.  int i,j,x,y,nLineSpacing,flag=TRUE;
  461.  UINT linelength;
  462.  DWORD fontcolor;
  463.  char color[32];
  464.  HDC hDC;
  465.  LOGFONT lf;
  466.  TEXTMETRIC tm;
  467.  HFONT hFont;
  468.  
  469.  strcpy(fontname,"Roman");
  470.  strcpy(fontsize,"12");
  471.  fontcolor = BLACK;
  472.  while (GetaLine(hFile,lineBuf,&linelength))
  473.   {
  474.     if (lineBuf[0]=='<'&&lineBuf[1]=='T') break;
  475.   }
  476.  if (lineBuf[0]!='<'||lineBuf[1]!='T') return FALSE;
  477.  hDC = GetDC(hWnd);
  478.  while (GetaLine(hFile,lineBuf,&linelength))
  479.   {if (linelength==0) break;
  480.     lineBuf[linelength] = NULL; strcpy(original,lineBuf);
  481. //    BWCCMessageBox(hWnd,lineBuf,"Test",MB_OK | MB_ICONINFORMATION);
  482.     token[0] = strtok(lineBuf," ");
  483.     parser(token[0],temp,linelength);
  484.     if (strcmp(temp,"(Font)")==0)
  485.      {
  486.       token[1] = strtok(NULL," ");
  487.       parser(token[1],fontname,linelength);
  488.       continue;
  489.      }
  490.     if (strcmp(temp,"(Color)")==0)
  491.      {
  492.       token[1] = strtok(NULL," ");
  493.       parser(token[1],color,linelength);
  494.       if (strcmp(color,"BLACK")==0) fontcolor = BLACK; else
  495.       if (strcmp(color,"BLUE")==0) fontcolor = BLUE; else
  496.       if (strcmp(color,"GREEN")==0) fontcolor = GREEN; else
  497.       if (strcmp(color,"CYAN")==0) fontcolor = CYAN; else
  498.       if (strcmp(color,"RED")==0) fontcolor = RED; else
  499.       if (strcmp(color,"MAGENTA")==0) fontcolor = MAGENTA; else
  500.       if (strcmp(color,"BROWN")==0) fontcolor = BROWN; else
  501.       if (strcmp(color,"LIGHTGRAY")==0) fontcolor = LIGHTGRAY; else
  502.       if (strcmp(color,"GRAY")==0) fontcolor = GRAY; else
  503.       if (strcmp(color,"LIGHTBLUE")==0) fontcolor = LIGHTBLUE; else
  504.       if (strcmp(color,"LIGHTGREEN")==0) fontcolor = LIGHTGREEN; else
  505.       if (strcmp(color,"LIGHTCYAN")==0) fontcolor = LIGHTCYAN; else
  506.       if (strcmp(color,"LIGHTRED")==0) fontcolor = LIGHTRED; else
  507.       if (strcmp(color,"LIGHTMAGENTA")==0) fontcolor = LIGHTMAGENTA; else
  508.       if (strcmp(color,"YELLOW")==0) fontcolor = YELLOW; else
  509.       if (strcmp(color,"WHITE")==0) fontcolor = WHITE;
  510.       continue;
  511.      }
  512.     if (strcmp(temp,"(Size)")==0)
  513.      {
  514.       token[1] = strtok(NULL," ");
  515.       parser(token[1],fontsize,linelength);
  516.       continue;
  517.      }
  518.     if (strcmp(temp,"(Position)")==0)
  519.      {
  520.       token[1] = strtok(NULL," ");
  521.       parser(token[1],temp,linelength);
  522.       x = atoi(temp);
  523.       token[2] = strtok(NULL," ");
  524.       parser(token[2],temp,linelength);
  525.       y = atoi(temp);
  526.       continue;
  527.      }
  528.     if (flag)
  529.      {lf.lfHeight      = atoi(fontsize);
  530.       lf.lfWidth       = 0;
  531.       lf.lfEscapement  = 0;
  532.       lf.lfOrientation = 0;
  533.       lf.lfWeight      = FW_NORMAL;
  534.       lf.lfItalic      = 0;
  535.       lf.lfUnderline   = 0;
  536.       lf.lfStrikeOut   = 0;
  537.       lf.lfCharSet     = ANSI_CHARSET;
  538.       lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
  539.       lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  540.       lf.lfQuality     = DEFAULT_QUALITY;
  541.       lf.lfPitchAndFamily = DEFAULT_PITCH | FF_ROMAN;
  542.       strcpy(lf.lfFaceName,fontname);
  543.       hFont = CreateFontIndirect(&lf);
  544.       SelectObject(hDC,hFont);
  545.       SetTextColor(hDC,fontcolor);
  546.       GetTextMetrics(hDC,&tm);
  547.       nLineSpacing = tm.tmHeight + tm.tmExternalLeading;
  548.      flag = FALSE;
  549.      }
  550.    TextOut(hDC,x,y,original,linelength);
  551.     TextOut(hmemDC,x,y,original,linelength);
  552.     y += nLineSpacing; // move down a line
  553.   }
  554.  ReleaseDC(hWnd,hDC);
  555.  DeleteObject(hFont);
  556.  return TRUE;
  557. }
  558.  
  559. int Read_Image(HWND hWnd,HFILE hFile)
  560. {
  561.  char lineBuf[128],temp[128],original[128];
  562.  char *token[6];
  563.  int i,j,x,y;
  564.  UINT linelength;
  565.  HDC hDC;
  566.  HBITMAP         hBitmap;
  567.  HPALETTE        hPal;
  568.  
  569.  while (GetaLine(hFile,lineBuf,&linelength))
  570.   {
  571.     if (lineBuf[0]=='<'&&lineBuf[1]=='I') break;
  572.   }
  573.  if (lineBuf[0]!='<'||lineBuf[1]!='I') return FALSE;
  574.  hDC = GetDC(hWnd);
  575.  while (GetaLine(hFile,lineBuf,&linelength))
  576.   {if (linelength==0) break;
  577.     lineBuf[linelength] = NULL; strcpy(original,lineBuf);
  578. //   BWCCMessageBox(hWnd,lineBuf,"Test",MB_OK | MB_ICONINFORMATION);
  579.     token[0] = strtok(lineBuf," ");
  580.     parser(token[0],temp,linelength);
  581.     if (strcmp(temp,"(Position)")==0)
  582.      {
  583.       token[1] = strtok(NULL," ");
  584.       parser(token[1],temp,linelength);
  585.       x = atoi(temp); // TextOut(hDC,500,350,temp,strlen(temp));
  586.       token[2] = strtok(NULL," ");
  587.       parser(token[2],temp,linelength);
  588.       y = atoi(temp); // TextOut(hDC,500,370,temp,strlen(temp));
  589.       continue;
  590.      }
  591.     CreateBitmapFromFile(hWnd,original,&hBitmap,&hPal);
  592.     DrawBitmap(hWnd,hBitmap,hPal,hDC,x,y);
  593.     BitBlt(hmemDC,0,0,WIDTH(cRect),HEIGHT(cRect),hDC,0,0,SRCCOPY);
  594.     DeleteObject(hBitmap);
  595.     DeleteObject(hPal);
  596.  
  597.   }
  598.  ReleaseDC(hWnd,hDC);
  599.  return TRUE;
  600. }
  601.  
  602. int Read_Buttons(HWND hWnd,HFILE hFile)
  603. {
  604.  
  605.  char lineBuf[128],temp[128];
  606.  int i,xPos,count=0,index=0;
  607.  UINT linelength;
  608.  HDC hDC;
  609.  HANDLE hInstance;
  610.  HMENU hMenuTemp;
  611.  RECT cRect;
  612.  
  613.  GetClientRect(hWnd,&cRect); xPos = 5;
  614.  hInstance = GetWindowWord(hWnd,GWW_HINSTANCE);
  615.  CreateWindow("BUTTON","Exit",
  616.       WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  617.       530,425,100,30,hWnd,MY_EXIT,hInstance,NULL);
  618.  while (GetaLine(hFile,lineBuf,&linelength))
  619.   {
  620.     if (lineBuf[0]=='['&&lineBuf[1]=='B') break;
  621.   }
  622.  if (lineBuf[0]!='['||lineBuf[1]!='B') return FALSE;
  623.  hDC = GetDC(hWnd);
  624.  while (GetaLine(hFile,lineBuf,&linelength))
  625.   {if (linelength==0)
  626.      {
  627.       break;
  628.      }
  629.     lineBuf[linelength] = NULL;
  630.     if (strcmp(lineBuf,"Images")==0) hMenuTemp = MY_IMAGES_BUTTON; else
  631.     if (strcmp(lineBuf,"Video")==0) hMenuTemp = MY_VIDEO_BUTTON; else
  632.     if (strcmp(lineBuf,"Voice")==0) hMenuTemp = MY_VOICE_BUTTON; else
  633.      {
  634.       if (index>7) continue;
  635.       strcpy(TextButton[index],lineBuf);
  636.       switch (index)
  637.         {
  638.          case 0: hMenuTemp = MY_TEXT_BUTTON_0; break;
  639.          case 1: hMenuTemp = MY_TEXT_BUTTON_1; break;
  640.          case 2: hMenuTemp = MY_TEXT_BUTTON_2; break;
  641.          case 3: hMenuTemp = MY_TEXT_BUTTON_3; break;
  642.          case 4: hMenuTemp = MY_TEXT_BUTTON_4; break;
  643.          case 5: hMenuTemp = MY_TEXT_BUTTON_5; break;
  644.          case 6: hMenuTemp = MY_TEXT_BUTTON_6; break;
  645.          case 7: hMenuTemp = MY_TEXT_BUTTON_7; break;
  646.          case 8: hMenuTemp = MY_TEXT_BUTTON_8; break;
  647.         }
  648.       index++;
  649.      }
  650.     if (count==0)
  651.      {CreateWindow("BUTTON",lineBuf,
  652.       WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  653.       xPos,425,100,30,hWnd,hMenuTemp,hInstance,NULL);
  654.       xPos += 105;
  655.       if (xPos+205>WIDTH(cRect)) {count++; xPos = 5;}
  656.      }
  657.     else
  658.      {CreateWindow("BUTTON",lineBuf,
  659.       WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  660.       xPos,390,100,30,hWnd,hMenuTemp,hInstance,NULL);
  661.       xPos += 105;
  662.       if (xPos+100>WIDTH(cRect)) break;
  663.      }
  664.   }
  665.  ReleaseDC(hWnd,hDC);
  666.  return TRUE;
  667. }
  668.  
  669. void Create_Child(HWND hWnd)
  670. {
  671.  HANDLE          hInstance;
  672.  HWND            hChild;
  673.  
  674.  hInstance = GetWindowWord(hWnd,GWW_HINSTANCE);
  675.  hChild = CreateWindow("ChildClass"," ",
  676.                                 WS_POPUP | WS_VSCROLL
  677.                                 // | WS_CAPTION | WS_MAXIMIZE | WS_SYSMENU,
  678.                                 ,
  679.                                 0,0,640,480,
  680.                                 hWnd,NULL,hInstance,NULL);
  681.  ShowWindow(hChild,SW_SHOWNORMAL);
  682.  SetFocus(hChild);
  683. }
  684.  
  685. int Read_Text(HWND hWnd,HFILE hFile,char *string)
  686. { // action=0 will text fit action=1 write text
  687.  char lineBuf[128],temp[128],original[128];
  688.  char *token[6],fontname[32],fontsize[4];
  689.  int i,j,x,y,flag=TRUE;
  690.  UINT linelength;
  691.  DWORD fontcolor;
  692.  char color[32];
  693.  HDC hDC;
  694.  LOGFONT lf;
  695.  TEXTMETRIC tm;
  696.  RECT cRect;
  697.  
  698.  strcpy(fontname,"Roman");
  699.  strcpy(fontsize,"20");
  700.  fontcolor = BLACK;
  701.  nNumLines = 0;
  702.  x = 10; y = 35;   hDC = GetDC(hWnd);
  703.  GetClientRect(hWnd,&cRect);
  704.  while (GetaLine(hFile,lineBuf,&linelength))
  705.   {
  706. //    lineBuf[linelength] = NULL;
  707.     if (strcmp(lineBuf,string)==0) break;
  708.   }
  709.  if (strcmp(lineBuf,string)!=0) return FALSE;
  710.  while (GetaLine(hFile,lineBuf,&linelength))
  711.   {/*if (linelength==0) break; */
  712. //    lineBuf[linelength] = NULL;
  713.     strcpy(original,lineBuf);
  714.     token[0] = strtok(lineBuf," ");
  715.     parser(token[0],temp,linelength);
  716.     if (strcmp(temp,string)==0) break;
  717.     if (strcmp(temp,"(Font)")==0)
  718.      {
  719.       token[1] = strtok(NULL," ");
  720.       parser(token[1],fontname,linelength);
  721.       continue;
  722.      }
  723.     if (strcmp(temp,"(Color)")==0)
  724.      {
  725.       token[1] = strtok(NULL," ");
  726.       parser(token[1],color,linelength);
  727.       if (strcmp(color,"BLACK")==0) fontcolor = BLACK; else
  728.       if (strcmp(color,"BLUE")==0) fontcolor = BLUE; else
  729.       if (strcmp(color,"GREEN")==0) fontcolor = GREEN; else
  730.       if (strcmp(color,"CYAN")==0) fontcolor = CYAN; else
  731.       if (strcmp(color,"RED")==0) fontcolor = RED; else
  732.       if (strcmp(color,"MAGENTA")==0) fontcolor = MAGENTA; else
  733.       if (strcmp(color,"BROWN")==0) fontcolor = BROWN; else
  734.       if (strcmp(color,"LIGHTGRAY")==0) fontcolor = LIGHTGRAY; else
  735.       if (strcmp(color,"GRAY")==0) fontcolor = GRAY; else
  736.       if (strcmp(color,"LIGHTBLUE")==0) fontcolor = LIGHTBLUE; else
  737.       if (strcmp(color,"LIGHTGREEN")==0) fontcolor = LIGHTGREEN; else
  738.       if (strcmp(color,"LIGHTCYAN")==0) fontcolor = LIGHTCYAN; else
  739.       if (strcmp(color,"LIGHTRED")==0) fontcolor = LIGHTRED; else
  740.       if (strcmp(color,"LIGHTMAGENTA")==0) fontcolor = LIGHTMAGENTA; else
  741.       if (strcmp(color,"YELLOW")==0) fontcolor = YELLOW; else
  742.       if (strcmp(color,"WHITE")==0) fontcolor = WHITE;
  743.       continue;
  744.      }
  745.     if (strcmp(temp,"(Size)")==0)
  746.      {
  747.       token[1] = strtok(NULL," ");
  748.       parser(token[1],fontsize,linelength);
  749.       continue;
  750.      }
  751.     if (strcmp(temp,"(Position)")==0)
  752.      {
  753.       token[1] = strtok(NULL," ");
  754.       parser(token[1],temp,linelength);
  755.       x = atoi(temp);
  756.       token[2] = strtok(NULL," ");
  757.       parser(token[2],temp,linelength);
  758.       y = atoi(temp);
  759.       continue;
  760.      }
  761.     if (flag)
  762.      {
  763.       lf.lfHeight      = atoi(fontsize);
  764.       lf.lfWidth       = 0;
  765.       lf.lfEscapement  = 0;
  766.       lf.lfOrientation = 0;
  767.       lf.lfWeight      = FW_NORMAL;
  768.       lf.lfItalic      = 0;
  769.       lf.lfUnderline   = 0;
  770.       lf.lfStrikeOut   = 0;
  771.       lf.lfCharSet     = ANSI_CHARSET;
  772.       lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
  773.       lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  774.       lf.lfQuality     = DEFAULT_QUALITY;
  775.       lf.lfPitchAndFamily = DEFAULT_PITCH | FF_ROMAN;
  776.       strcpy(lf.lfFaceName,fontname);
  777.       hFontText = CreateFontIndirect(&lf);
  778.       SelectObject(hDC,hFontText);
  779.       SetTextColor(hDC,fontcolor);
  780.       GetTextMetrics(hDC,&tm);
  781.       nLineSpacing = tm.tmHeight + tm.tmExternalLeading;
  782.       flag = FALSE;
  783.      }
  784.     strcpy(Text[nNumLines],original);
  785.     nNumLines++; y += nLineSpacing;
  786.   }
  787.  ReleaseDC(hWnd,hDC);
  788.  DeleteObject(hFontText);
  789.  if (y<HEIGHT(cRect)) return FALSE; else return nNumLines;
  790. }
  791.  
  792. int GetFileName(HWND hWnd,HFILE hFile,char *string)
  793. {
  794.  char lineBuf[128];
  795.  UINT linelength;
  796.  
  797.  while (GetaLine(hFile,lineBuf,&linelength))
  798.   {
  799.     if (strcmp(lineBuf,string)==0) break;
  800.   }
  801.  if (strcmp(lineBuf,string)!=0) return FALSE;
  802.  GetaLine(hFile,szString,&linelength);
  803. }
  804. #pragma argsused
  805. int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,LPSTR lpszCmdLine,
  806.                          int nCmdShow)
  807.  {
  808.   HWND     hWnd;
  809.   MSG        msg;
  810.   WNDCLASS     wndclass;
  811.  
  812.   if (!hPrevInstance)
  813.     {
  814.      wndclass.style            =CS_HREDRAW | CS_VREDRAW;
  815.      wndclass.lpfnWndProc   =WndProc;
  816.      wndclass.cbClsExtra        =0;
  817.      wndclass.cbWndExtra        =0;
  818.      wndclass.hInstance        =hInstance;
  819.      wndclass.hIcon            =LoadIcon(hInstance,"Resume");
  820.      wndclass.hCursor            =LoadCursor(NULL,IDC_ARROW);
  821.      wndclass.hbrBackground    =GetStockObject(WHITE_BRUSH);
  822.      wndclass.lpszMenuName    ="MENU_1";
  823.      wndclass.lpszClassName    ="MyClass";
  824.      if (!RegisterClass(&wndclass)) return (0);
  825.  
  826.      wndclass.style            =CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  827.      wndclass.lpfnWndProc   =ChildProc;
  828.      wndclass.hIcon            =NULL;
  829.      wndclass.hCursor            =LoadCursor(NULL,IDC_ARROW);
  830.      wndclass.hbrBackground    =GetStockObject(WHITE_BRUSH);
  831.      wndclass.lpszMenuName    =NULL;
  832.      wndclass.lpszClassName    ="ChildClass";
  833.      if (!RegisterClass(&wndclass))
  834.       {
  835.         ErrorMsg(hWnd,"Could not register editor child window");
  836.         return(0);
  837.       }
  838.     }
  839.   hWnd = CreateWindow("MyClass",szProgName,
  840.                          //     WS_OVERLAPPEDWINDOW,
  841.                              WS_MAXIMIZE | WS_SYSMENU | WS_MINIMIZEBOX,
  842.                              0,
  843.                              0,
  844.                              640,
  845.                              480,
  846.                              NULL,
  847.                              NULL,
  848.                              hInstance,
  849.                              NULL);
  850.   ShowWindow(hWnd,nCmdShow);
  851.  
  852.   while(GetMessage(&msg,NULL,NULL,NULL))
  853.     {
  854.      TranslateMessage(&msg);
  855.      DispatchMessage(&msg);
  856.     }
  857.   return(msg.wParam);
  858.  }
  859.  
  860. long FAR PASCAL _export WndProc(HWND hWnd,UINT wMessage,UINT wParam,LONG lParam)
  861.  {
  862.   HBRUSH          hBrush,hOldBrush,hmemOldBrush;
  863.   HPEN            hPen,hOldPen,hmemOldPen;
  864.   HBITMAP         hBitmap,hOldBitmap,hmemOldBitmap;
  865.   HDC             hDC;
  866.   HPALETTE        hPal;
  867. //  HDIB            hDIB;
  868.   HFONT           hFont;
  869.   HCURSOR         hCursor,hOldCursor;
  870.   PAINTSTRUCT     ps;
  871.   static POINT    ptBegin,ptEnd;
  872.   OPENFILENAME    ofn;
  873.   static HWND     hChild = NULL,hImage = NULL;
  874.   HANDLE          hInstance;
  875.   char            temp[128];
  876.   HFILE           hFile;
  877.   PCXHEAD         pcxHd;
  878.   int             i,j,length;
  879.   static int      ydist;
  880. //  static PALETTEENTRY peEntry[256];
  881.  
  882.   static COLORREF crColor = RGB(0,128,0);
  883.   LPCSTR          szFilter[] = {"All files (*.*)","*.*",
  884.                               "BMP files (*.BMP)","*.BMP",
  885.                               "PCX files (*.PCX)","*.PCX",
  886.                               ""};
  887.   CHOOSECOLOR     cc;
  888.   static DWORD    dwCustColors[16]= {
  889.   RGB(0,   0,   0),    /* black   */       /* Almost Standard VGA 16 color */
  890.   RGB(0,   0,0xC0),    /* blue    */
  891.   RGB(0,0xC0,   0),    /* green   */
  892.   RGB(   0,0xC0,0xC0), /* cyan    */
  893.   RGB(0xC0,   0,   0), /* red     */
  894.   RGB(0xC0,   0,0xC0), /* magenta */
  895.   RGB(0xFF,0xC0,0xA0), /* flesh   */
  896.   RGB(0xC0,0xC0,0xC0), /* lt gray */
  897.   RGB(0x5C,0x5C,0x5C), /* gray    */
  898.   RGB(0x3F,0x3F,0xFF), /* lt blue */
  899.   RGB(0x3F,0xFF,0x3F), /* lt green */
  900.   RGB(0x3F,0xFF,0xFF), /* lt cyan  */
  901.   RGB(0xFF,0x3F,0x3F), /* lt red   */
  902.   RGB(0xFF,0x3F,0xFF), /* lt magenta */
  903.   RGB(0xFF,0xFF,0x3F), /* yellow     */
  904.   RGB(0xFF,0xFF,0xFF)}; /* white      */
  905.   cc.lStructSize    = sizeof(CHOOSECOLOR);
  906.   cc.hwndOwner      = hWnd;
  907.   cc.hInstance      = NULL;
  908.   cc.rgbResult      = crColor;
  909.   cc.lpCustColors   = dwCustColors;
  910.   cc.Flags          = CC_RGBINIT | CC_FULLOPEN;
  911.   cc.lCustData      = 0L;
  912.   cc.lpfnHook       = NULL;
  913.   cc.lpTemplateName = NULL;
  914.  
  915.   switch(wMessage)
  916.     {
  917.      case WM_COMMAND:switch (wParam)
  918.           {
  919.             case MY_TEXT_BUTTON_0:strcpy(ButtonTitle,TextButton[0]);
  920.                                          Create_Child(hWnd); break;
  921.             case MY_TEXT_BUTTON_1:strcpy(ButtonTitle,TextButton[1]);
  922.                                          Create_Child(hWnd); break;
  923.             case MY_TEXT_BUTTON_2:strcpy(ButtonTitle,TextButton[2]);
  924.                                          Create_Child(hWnd); break;
  925.             case MY_TEXT_BUTTON_3:strcpy(ButtonTitle,TextButton[3]);
  926.                                          Create_Child(hWnd); break;
  927.             case MY_TEXT_BUTTON_4:strcpy(ButtonTitle,TextButton[4]);
  928.                                          Create_Child(hWnd); break;
  929.             case MY_TEXT_BUTTON_5:strcpy(ButtonTitle,TextButton[5]);
  930.                                          Create_Child(hWnd); break;
  931.             case MY_TEXT_BUTTON_6:strcpy(ButtonTitle,TextButton[6]);
  932.                                          Create_Child(hWnd); break;
  933.             case MY_TEXT_BUTTON_7:strcpy(ButtonTitle,TextButton[7]);
  934.                                          Create_Child(hWnd); break;
  935.             case MY_TEXT_BUTTON_8:strcpy(ButtonTitle,TextButton[8]);
  936.                                          Create_Child(hWnd); break;
  937.             case MY_IMAGES_BUTTON:strcpy(ButtonTitle,"Images");
  938.                                         Create_Child(hWnd);
  939.                                         break;
  940.             case MY_VIDEO_BUTTON:strcpy(ButtonTitle,"Video");
  941.                                         Create_Child(hWnd);
  942.                                         break;
  943.             case MY_VOICE_BUTTON:hFile = _lopen(szPath,READ);
  944.                                         if (hFile == HFILE_ERROR) break;
  945.                                         GetFileName(hWnd,hFile,"(Voice)");
  946.                               _lclose(hFile);
  947.                                         sndPlaySound(szString,SND_ASYNC);
  948.                                         break;
  949.             case MY_EXIT:        SendMessage(hWnd,WM_CLOSE,0,0L);
  950.                                         break;
  951.           }
  952.          break;
  953.  
  954.         case WM_LBUTTONDOWN:
  955.                                   break;
  956.         case WM_LBUTTONUP:/* if (wParam & MK_RBUTTON)
  957.                                  {hFile = _lopen(szPath,READ);
  958.                                   if (hFile == HFILE_ERROR)
  959.                                     {
  960.                                      wsprintf(temp,"\n %s Resume.txt file not found",szPath);
  961.                                      BWCCMessageBox(hWnd,temp,"Error",MB_OK | MB_ICONINFORMATION);
  962.                                      SendMessage(hWnd,WM_CLOSE,0,0L);
  963.                                     }
  964.                                   Read_Title(hWnd,hFile);
  965.                                   _llseek(hFile,0L,0);
  966.                                   Read_Image(hWnd,hFile);
  967.                                   _lclose(hFile);
  968.                                  } */
  969.                                 break;
  970.      case WM_MOUSEMOVE:if (wParam & MK_LBUTTON)
  971.                               {
  972.  
  973.                               }
  974.                              break;
  975.      case WM_CREATE:GetClientRect(hWnd,&cRect);
  976.                          hDC = GetDC(hWnd);
  977.                          hmemDC = CreateCompatibleDC(hDC);
  978.                          hmemBitmap = CreateCompatibleBitmap(hDC,WIDTH(cRect),HEIGHT(cRect));
  979.                          hmemOldBitmap = SelectObject(hmemDC,hmemBitmap);
  980.                          hPen = CreatePen(PS_SOLID,1,RGB(255,255,255));
  981.                          hBrush = CreateSolidBrush(RGB(255,255,255));
  982.                          SelectObject(hmemDC,hPen);
  983.                          SelectObject(hmemDC,hBrush);
  984.                          Rectangle(hmemDC,0,0,WIDTH(cRect),HEIGHT(cRect));
  985.                          DeleteObject(hBrush);
  986.                          DeleteObject(hPen);
  987.                          hFile = _lopen(szPath,READ);
  988.                          if (hFile == HFILE_ERROR)
  989.                           {
  990.                             wsprintf(temp,"\n %s Resume.txt file not found",szPath);
  991.                             BWCCMessageBox(hWnd,temp,"Error",MB_OK | MB_ICONINFORMATION);
  992.                             SendMessage(hWnd,WM_CLOSE,0,0L);
  993.                           }
  994.                          Read_Buttons(hWnd,hFile);
  995.                          _lclose(hFile);
  996.                          ReleaseDC(hWnd,hDC);
  997.                          sndPlaySound("CHIMES.WAV",SND_ASYNC);
  998.                          break;
  999.      case WM_MOVE:/* MessageBox(hWnd,"WM_MOVE",szProgName,MB_OK); */break;
  1000.      case WM_SIZE:/* MessageBox(hWnd,"WM_SIZE",szProgName,MB_OK); */break;
  1001.      case WM_PAINT:hDC = BeginPaint(hWnd,&ps);
  1002. //                        MessageBox(hWnd,"WM_PAINT",szProgName,MB_OK);
  1003.                         GetClientRect(hWnd,&cRect);
  1004.                         hFile = _lopen(szPath,READ);
  1005.                         if (hFile == HFILE_ERROR) SendMessage(hWnd,WM_CLOSE,0,0L);
  1006.                         while (Read_Title(hWnd,hFile)) {}
  1007.                         _llseek(hFile,0L,0);
  1008.                         while (Read_Image(hWnd,hFile)) {}
  1009.                         _lclose(hFile);
  1010.                   // BitBlt not needed - this needs cleaning up
  1011.                         BitBlt(hDC,0,0,WIDTH(cRect),HEIGHT(cRect),hmemDC,0,0,SRCCOPY);
  1012.                         EndPaint(hWnd,&ps);
  1013.                         break;
  1014.      case WM_CLOSE:if (BWCCMessageBox(hWnd,"\n\n     Exit, are you sure?",szProgName,
  1015.                                                  MB_YESNO | MB_ICONQUESTION)==IDYES)
  1016.                          {if (Shareware)
  1017.                             {
  1018.                              WinHelp(hWnd,"resume.hlp",HELP_KEY,(DWORD)(LPSTR)"Registration");
  1019.                             }
  1020.  
  1021.                           DeleteObject(hmemBitmap);
  1022.                           DeleteDC(hmemDC);
  1023.                           DestroyWindow(hWnd);
  1024.                          }
  1025.                         break;
  1026.      case WM_DESTROY:PostQuitMessage(0);break;
  1027.      default: return DefWindowProc(hWnd,wMessage,wParam,lParam);
  1028.     }
  1029.   return (0L);
  1030.  }
  1031.  
  1032. long FAR PASCAL ChildProc(HWND hChild,UINT wMessage,UINT wParam,LONG lParam)
  1033.  {
  1034.   PAINTSTRUCT      ps;
  1035.   HANDLE           hInstance;
  1036.   static HFONT     hFont;
  1037.   HFILE            hFile;
  1038.   HBITMAP          hBitmap;
  1039.   HPALETTE         hPal;
  1040.   HDC              hDC;
  1041.   TEXTMETRIC       tm;
  1042.   RECT             cRect;
  1043.   DWORD            TextColor;
  1044.   char             temp[128];
  1045.   int              i,j;
  1046.   UINT             linelength;
  1047.   // int VertOldPos=0,VertScrollPos=0,VertMaxScroll;
  1048.   static int       yChar,yPage,xPage,yPos;
  1049.   LPSTR            *lpImage;
  1050.  
  1051.   // This function has a private DC, do not use ReleaseDC();
  1052.   switch (wMessage)
  1053.     {
  1054.      case WM_COMMAND:
  1055.                         switch (wParam)
  1056.                          {case MY_EDIT_RETURN:mciSendString("close all",achString,128,hChild);
  1057.                                                      SendMessage(hChild,WM_CLOSE,0,0L);
  1058.                                                      break;
  1059.  
  1060.                           case MY_VIDEO_PLAY:if (strcmp(ButtonTitle,"Video")==0)
  1061.                                                      {
  1062.                                                       mciSendString("play The_AVI",achString,128,hChild);
  1063.                                                      }
  1064.                                                     break;
  1065.                           case MY_VIDEO_PAUSE:mciSendString("pause The_AVI",achString,128,hChild);
  1066.                                                     break;
  1067.                           case MY_VIDEO_REWIND:mciSendString("seek The_AVI to start",achString,128,hChild);
  1068.                                                     break;
  1069.                           case MY_IMAGE_NEXT:nImageNum++;
  1070.                                                     if (nImageNum>=nNumImages) nImageNum = 0;
  1071.                                                     InvalidateRect(hChild,NULL,TRUE);
  1072. //  wsprintf(temp,"nImageNum = %d nNumImages = %d",nImageNum,nNumImages);
  1073. //  BWCCMessageBox(hChild,temp,"Testing",MB_OK | MB_ICONINFORMATION);
  1074.                                                     break;
  1075.                           case MY_IMAGE_BACK:nImageNum--;
  1076.                                                     if (nImageNum<0) nImageNum = nNumImages-1;
  1077.                                                     InvalidateRect(hChild,NULL,TRUE);
  1078.                                                     break;
  1079.                          }
  1080.                         break;
  1081.      case WM_CREATE:hInstance = GetWindowWord(hChild,GWW_HINSTANCE);
  1082.                         GetClientRect(hChild,&cRect);
  1083.                         CreateWindow("BUTTON","Return",
  1084.                                          WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  1085.                                          WIDTH(cRect)-90,HEIGHT(cRect)-40,80,30,
  1086.                                          hChild,MY_EDIT_RETURN,hInstance,NULL);
  1087.                         if (strcmp(ButtonTitle,"Video")==0)
  1088.                          {
  1089.                           CreateWindow("BUTTON","Play",
  1090.                                          WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  1091.                                          WIDTH(cRect)-180,HEIGHT(cRect)-40,80,30,
  1092.                                          hChild,MY_VIDEO_PLAY,hInstance,NULL);
  1093.                           CreateWindow("BUTTON","Pause",
  1094.                                          WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  1095.                                          WIDTH(cRect)-270,HEIGHT(cRect)-40,80,30,
  1096.                                          hChild,MY_VIDEO_PAUSE,hInstance,NULL);
  1097.                           CreateWindow("BUTTON","Rewind",
  1098.                                          WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  1099.                                          WIDTH(cRect)-360,HEIGHT(cRect)-40,80,30,
  1100.                                          hChild,MY_VIDEO_REWIND,hInstance,NULL);
  1101.  
  1102.                     strcpy(temp,"open ");
  1103.                           hFile = _lopen(szPath,READ);
  1104.                           if (hFile == HFILE_ERROR) break;
  1105.                           GetFileName(hChild,hFile,"(Video)");
  1106.                           _lclose(hFile);
  1107.                           strcat(temp,szString);
  1108.                           strcat(temp," alias The_AVI");
  1109.                           mciSendString(temp,achString,128,hChild);
  1110.                     mciSendString("put The_AVI window at 120 120 0 0",achString,128,hChild);
  1111.                          }
  1112.                         if (strcmp(ButtonTitle,"Images")==0)
  1113.                          {
  1114.                           CreateWindow("BUTTON","Next",
  1115.                                          WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  1116.                                          WIDTH(cRect)-180,HEIGHT(cRect)-40,80,30,
  1117.                                          hChild,MY_IMAGE_NEXT,hInstance,NULL);
  1118.                           CreateWindow("BUTTON","Back",
  1119.                                          WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE,
  1120.                                          WIDTH(cRect)-270,HEIGHT(cRect)-40,80,30,
  1121.                                          hChild,MY_IMAGE_BACK,hInstance,NULL);
  1122.                           // get list of images
  1123.                           hFile = _lopen(szPath,READ);
  1124.                           if (hFile == HFILE_ERROR) SendMessage(hChild,WM_CLOSE,0,0L);
  1125.                           strcpy(temp,"("); strcat(temp,ButtonTitle); strcat(temp,")");
  1126.                           while (GetaLine(hFile,szString,&linelength))
  1127.                             {
  1128.                              if (strcmp(szString,temp)==0) break;
  1129.                             }
  1130.                           if (strcmp(szString,temp)!=0) SendMessage(hChild,WM_CLOSE,0,0L);
  1131.                           nImageNum = 0; nNumImages = 0;
  1132.                           while (GetaLine(hFile,szString,&linelength))
  1133.                             {
  1134.                              if (linelength<3) break;
  1135.                              lstrcpy(images[nNumImages],szString);
  1136.                              GetaLine(hFile,szString,&linelength);
  1137.                              if (linelength<3) break;
  1138.                              lstrcpy(captions[nNumImages++],szString);
  1139.                             }
  1140. //  wsprintf(temp,"nImageNum = %d nNumImages = %d",nImageNum,nNumImages);
  1141. //  BWCCMessageBox(hChild,temp,"Testing",MB_OK | MB_ICONINFORMATION);
  1142.  
  1143.                           _lclose(hFile);
  1144.                          }
  1145.                         hDC = GetDC(hChild);
  1146.                         if (strcmp(ButtonTitle,"Video")!=0&&strcmp(ButtonTitle,"Images")!=0)
  1147.                          {
  1148.                           hFile = _lopen(szPath,READ);
  1149.                           if (hFile == HFILE_ERROR) SendMessage(hChild,WM_CLOSE,0,0L);
  1150.                           strcpy(temp,"("); strcat(temp,ButtonTitle); strcat(temp,")");
  1151.                           VertOldPos = 0; VertScrollPos = 0;
  1152.                           VertMaxScroll = Read_Text(hChild,hFile,temp);
  1153.                           _lclose(hFile);
  1154.                           GetClientRect(hChild,&cRect);
  1155.                           VertMaxScroll -= (HEIGHT(cRect)-40)/nLineSpacing;
  1156.                           if (VertMaxScroll<0) VertMaxScroll = 0;
  1157.                           SetScrollRange(hChild,SB_VERT,0,VertMaxScroll,FALSE);
  1158.                           SetScrollPos(hChild,SB_VERT,0,TRUE);
  1159.                          }
  1160.                         else
  1161.                          {
  1162.                           VertMaxScroll = 0;
  1163.                           SetScrollRange(hChild,SB_VERT,0,VertMaxScroll,FALSE);
  1164.                           SetScrollPos(hChild,SB_VERT,0,TRUE);
  1165.                          }
  1166.                         break;
  1167.      case WM_VSCROLL:
  1168.         switch(wParam)
  1169.          {
  1170.           case SB_THUMBPOSITION:
  1171.                               VertOldPos = VertScrollPos;
  1172.                               VertScrollPos = LOWORD(lParam);
  1173.                               break;
  1174.           case SB_LINEDOWN:
  1175.                               VertOldPos = VertScrollPos;
  1176.                               VertScrollPos++;
  1177.                               VertScrollPos = VertScrollPos > VertMaxScroll ?
  1178.                                                     VertMaxScroll : VertScrollPos;
  1179.                               break;
  1180.           case SB_LINEUP:
  1181.                               VertOldPos = VertScrollPos;
  1182.                               VertScrollPos--;
  1183.                               VertScrollPos = VertScrollPos < 0 ? 0 : VertScrollPos;
  1184.                               break;
  1185.           case SB_PAGEDOWN:
  1186.                               VertOldPos = VertScrollPos;
  1187.                               VertScrollPos += 10;
  1188.                               VertScrollPos = VertScrollPos > VertMaxScroll ?
  1189.                                                     VertMaxScroll : VertScrollPos;
  1190.                               break;
  1191.           case SB_PAGEUP:
  1192.                               VertOldPos = VertScrollPos;
  1193.                               VertScrollPos -= 10;
  1194.                               VertScrollPos = VertScrollPos < 0 ? 0 : VertScrollPos;
  1195.                               break;
  1196.                          }
  1197.           SetScrollPos(hChild,SB_VERT,VertScrollPos,TRUE);
  1198.           InvalidateRect(hChild,NULL,TRUE);
  1199.           break;
  1200.      case WM_LBUTTONDOWN:break;
  1201.      case WM_PAINT:
  1202.                         BeginPaint(hChild,&ps);
  1203.                         TextColor = GetTextColor(ps.hdc);
  1204.                         SetTextColor(ps.hdc,LIGHTBLUE);
  1205.                         TextOut(ps.hdc,10,10,ButtonTitle,strlen(ButtonTitle));
  1206.                         SetTextColor(ps.hdc,TextColor);
  1207.                         j = 0;
  1208.                         if (strcmp(ButtonTitle,"Video")!=0&&strcmp(ButtonTitle,"Images")!=0)
  1209.                           for (i=VertScrollPos;i<nNumLines;i++)
  1210.                          {
  1211.                           TextOut(ps.hdc,25,40+j*nLineSpacing,Text[i],strlen(Text[i]));
  1212.                           j++;
  1213.                          }
  1214.                         if (strcmp(ButtonTitle,"Images")==0)
  1215.                          {
  1216.                           lstrcpy(temp,images[nImageNum]);
  1217.                     //      TextOut(ps.hdc,400,35,temp,strlen(temp));
  1218.                           CreateBitmapFromFile(hChild,temp,&hBitmap,&hPal);
  1219.                           DrawBitmap(hChild,hBitmap,hPal,ps.hdc,-1,-1);
  1220.                           BitBlt(hmemDC,0,0,WIDTH(cRect),HEIGHT(cRect),ps.hdc,0,0,SRCCOPY);
  1221.                     TextOut(ps.hdc,25,400,captions[nImageNum],strlen(captions[nImageNum]));
  1222.                           DeleteObject(hBitmap);
  1223.                           DeleteObject(hPal);
  1224.                          }
  1225.                         EndPaint(hChild,&ps);
  1226.                         break;
  1227.      case WM_CLOSE:// DeleteObject(hFont);
  1228.                         DestroyWindow(hChild);
  1229.                         break;
  1230.      default:return DefWindowProc(hChild,wMessage,wParam,lParam);
  1231.     }
  1232.  
  1233.   return(0);
  1234.  }
  1235.  
  1236.  
  1237.